﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .form .formValue input.form-control {
        height: 34px;
        line-height: 34px;
    }

    .form-control {
        padding: 0px;
    }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    ul {
        list-style: none;
        float: left;
        -webkit-padding-start: 10px;
    }

    ul li {
        list-style-type: none;
        float: left;
    }

    .active {
        border: 1px solid #1ABC9C;
    }

    .active:hover {
        background-color: #1ABC9C;
        color: #fff;
        text-decoration: none;
     }

    a {
        padding: 3px 10px;
    }

    a:hover {
        border: 1px solid #1ABC9C;
        text-decoration: none;
    }
</style>
<script>
    var F_ClientId = "";
    var F_BrandId = "";
    var F_ProjectId = "";
    var F_ContactId = "";
    var resultData = {};
    $(function () {
        F_ClientId = $.request("F_ClientId");
        F_BrandId = $.request("F_BrandId");
        F_ProjectId = $.request("F_ProjectId");
        F_ContactId = $.request("F_ContactId");
        $("#F_ActivityCityId").select2({ multiple: true });
        GetInit();       
    });

    function GetInit() {
        resultData = getCache("CLIENT_ADDMEMAND");
        if (!resultData || resultData.length <= 0) {
            $.ajax({
                url: "/ClientManager/ClientInfos/GetDemandItems",
                dataType: "json",
                async: false,
                success: function (data) {
                    resultData = data;
                    InitControl();
                    setCache("CLIENT_ADDMEMAND", data);
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        } else {
            InitControl();
        }
    }    

    function InitControl() {
        var F_ActivityType = resultData.F_ActivityType;
        var First_ActivityType = resultData.First_ActivityType;
        var strHtml = "";
        for (var j = 0; j < First_ActivityType.length; j++) {
            strHtml += "<option style=\"font-weight:bold;\" label='" + First_ActivityType[j]["F_ItemName"] + "'>";
            for (var i = 0; i < F_ActivityType.length; i++) {
                if (First_ActivityType[j].F_ItemCode == F_ActivityType[i].F_Description) {
                    strHtml += "<option value='" + F_ActivityType[i].F_ItemCode + "'>" + "&nbsp;&nbsp;&nbsp;&nbsp;" + F_ActivityType[i].F_ItemName + "</option>";
                }
            }
            strHtml += "</option>"; 
        }
        $("#F_ActivityType").append(strHtml);

        var F_ActivityCityId = resultData.F_ActivityCityId;
        for (var i = 0; i < F_ActivityCityId.length; i++) {
            $("#F_ActivityCityId").append("<option value='" + F_ActivityCityId[i].F_EnCode + "'>" + F_ActivityCityId[i].F_FullName + "</option>");
        }

        var F_SiteType = resultData.F_SiteType;
        for (var i = 0; i < F_SiteType.length; i++) {
            $("#F_SiteType").append("<option value='" + F_SiteType[i].F_ItemCode + "'>" + F_SiteType[i].F_ItemName + "</option>");
        } 

        var F_ZkIndustryId = resultData.F_IndustryId;
        for (var i = 0; i < F_ZkIndustryId.length; i++) {
            $("#F_ZkIndustryId").append("<option value='" + F_ZkIndustryId[i].F_ItemCode + "'>" + F_ZkIndustryId[i].F_ItemName + "</option>");
        }
    }

    function submitForm() {
        if (!$('#projectForm').formValid()) {
            return false;
        }        
        var F_ActivityTheme = $("#F_ActivityTheme").val();
        var F_ActivityType = $("#F_ActivityType").val();
        var F_DemandCash = $("#F_DemandCash").val();

        var F_BuildDate = $("#F_BuildDate").val();
        var F_ActivityStartDate = $("#F_ActivityStartDate").val();
        var F_ActivityEndDate = $("#F_ActivityEndDate").val();
        var F_ACityIdList = $("#F_ActivityCityId").select2("data");
        var F_ActivityCityId = "";
        for (var i = 0; i < F_ACityIdList.length; i++) {
            if (i == F_ACityIdList.length - 1) {
                F_ActivityCityId += F_ACityIdList[i].id;
            } else {
                F_ActivityCityId += F_ACityIdList[i].id + ",";
            }
        }

        var F_SiteType = $("#F_SiteType").val();
        var F_SiteArea = $("#F_SiteArea").val();
        var F_Source = $("#F_Source").val();
        var F_PersionNumber = $("#F_PersionNumber").val();
        var F_Height = $("#F_Height").val();
        var F_Note = $("#F_Note").val();
        var F_Intention = $("#F_Intention").val();
        var F_ZkIndustryId = $("#F_ZkIndustryId").val();
        $.submitForm({
            url: "/ClientManager/ClientInfos/SubmitDemandData",
            param: {
                F_ClientId: F_ClientId, F_BrandId: F_BrandId, F_ProjectId: F_ProjectId, F_ContactId: F_ContactId,
                F_ActivityTheme: F_ActivityTheme, F_ActivityType: F_ActivityType, F_DemandCash: F_DemandCash, F_BuildDate: F_BuildDate,
                F_ActivityStartDate: F_ActivityStartDate, F_ActivityEndDate: F_ActivityEndDate, F_ActivityCityId: F_ActivityCityId, F_SiteType: F_SiteType, F_SiteArea: F_SiteArea,
                F_Source: F_Source, F_PersionNumber: F_PersionNumber, F_Height: F_Height, F_Note: F_Note, F_Intention: F_Intention, F_ZkIndustryId: F_ZkIndustryId
            },
            success: function () {
                top.frames["editForm"].$("#gridListqq").trigger("reloadGrid");
            }
        })
    }
</script>
<div id="ProjectsDetail">
    <form id="projectForm">
        <table class="form">         
            <tr>
                <td colspan="6" class="interval">需求信息</td>
            </tr>
            <tr>
                <td colspan="6">
                    <table class="form">
                        <tr>
                            <td class="formTitle">需求来源</td>
                            <td class="formValue">
                                <select id="F_Source" name="F_Source" class="form-control required">
                                    <option value="">==请选择需求来源==</option>
                                    <option value="0">400电话</option>
                                    <option value="1">销售自拓</option>
                                    <option value="2">网站订单</option>
                                    <option value="3">小程序订单</option>
                                    <option value="4">App订单</option>
                                </select>
                            </td>
                            <td class="formTitle">所属行业</td>
                            <td class="formValue">
                                <select id="F_ZkIndustryId" name="F_ZkIndustryId" class="form-control">
                                    <option value="">==请选择行业==</option>
                                </select>
                            </td>
                            <td class="formTitle">活动主题</td>
                            <td class="formValue">
                                <input type="text" id="F_ActivityTheme" name="F_ActivityTheme" class="form-control required" placeholder="请输入活动主题" />
                            </td>                            
                        </tr>
                        <tr>         
                            <td class="formTitle">活动类型</td>
                            <td class="formValue">
                                <select id="F_ActivityType" name="F_ActivityType" class="form-control">
                                    <option value="">==请选择活动类型==</option>
                                </select>
                            </td>
                            <td class="formTitle">搭建日期</td>
                            <td class="formValue">
                                <input type="text" id="F_BuildDate" name="F_BuildDate" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="请输入活动搭建日期" />
                            </td>
                            <td class="formTitle">活动开始日期</td>
                            <td class="formValue">
                                <input type="text" id="F_ActivityStartDate" name="F_ActivityStartDate" class="form-control input-wdatepicker required" onfocus="WdatePicker()" placeholder="请输入活动开始日期" />
                            </td>
                            
                        </tr>
                        <tr>
                            <td class="formTitle">活动结束日期</td>
                            <td class="formValue">
                                <input type="text" id="F_ActivityEndDate" name="F_ActivityEndDate" class="form-control input-wdatepicker required" onfocus="WdatePicker()" placeholder="请输入活动结束日期" />
                            </td>
                            <td class="formTitle">预算金额</td>
                            <td class="formValue">
                                <input type="text" id="F_DemandCash" name="F_DemandCash" class="form-control required number" placeholder="请输入预算金额" />
                            </td>
                            <td class="formTitle">活动城市</td>
                            <td class="formValue">
                                <select id="F_ActivityCityId" name="F_ActivityCityId" class="form-control required"></select>
                            </td>
                                                      
                        </tr>
                        <tr>
                            <td class="formTitle">场地类型</td>
                            <td class="formValue">
                                <select id="F_SiteType" name="F_SiteType" class="form-control required">
                                    <option value="">==请选择场地类型==</option>
                                </select>
                            </td>  
                            <td class="formTitle">活动人数</td>
                            <td class="formValue">
                                <input type="text" id="F_PersionNumber" name="F_PersionNumber" class="form-control number" placeholder="请输入活动人数" />
                            </td>
                            <td class="formTitle">场地面积(㎡)</td>
                            <td class="formValue">
                                <input type="text" id="F_SiteArea" name="F_SiteArea" class="form-control number" placeholder="请输入场地面积" />
                            </td>
                                                     
                        </tr>
                        <tr>
                            <td class="formTitle">层高(m)</td>
                            <td class="formValue">
                                <input type="text" id="F_Height" name="F_Height" class="form-control number" placeholder="请输入层高" />
                            </td>  
                            <td class="formTitle"></td>
                            <td class="formValue"></td> 
                            <td class="formTitle"></td>
                            <td class="formValue"></td> 
                        </tr>
                        <tr>
                            <td class="formTitle">意向场地</td>
                            <td class="formValue" colspan="5">
                                <textarea rows="2" id="F_Intention" name="F_Intention" class="form-control" placeholder="请输入意向场地" style="width:99%;"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">备注</td>
                            <td class="formValue" colspan="5">
                                <textarea rows="3" id="F_Note" name="F_Note" class="form-control" placeholder="请输入备注信息" style="width:99%;"></textarea>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
</div>